<?php

/**
 * 
 * 
 *
 */
abstract class Quad_Observable {
	
	protected $_observers = array();
	protected $_notifyObservers = true;
	
	public function enableObserverNotification() {
		$this->_notifyObservers = true;
	}
	
	public function disableObserverNotification() {
		$this->_notifyObservers = false;
	}	
	
	public function isObserverNotificationEnabled() {
		return $this->_notifyObservers;
	}
	
	public function subscribe($eventName,$callback,$addlData=array()) {
	
	}
	
	public function unsubscribe($eventName,$callback) {
		
	}
	
	public function notify($eventName,$addlData=array(),$stoppable=false,$preventable=false) {
		$event = new Quad_Observable_Event($this,$addlData,$stoppable,$preventable);
		foreach ($this->_observers as $o) {
			$event->setProperties($o['addlData']);
			call_user_func($o['callback'],$event);
			if ($event->isStopped()) {
				break;
			}
		}
		return $this;
	}
  
}